package com.eureka.controller;


import com.provice.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@RestController
public class ProviderController {

    private static final Logger logger = LoggerFactory.getLogger(ProviderController.class);

    @GetMapping("/")
    public String index(){
        return "Hello index!";
    }

    //http://localhost:8003/xm?name=兰兰&content=下班一起去看电影
    @RequestMapping(value = "/xm",method = RequestMethod.GET)
    public String sayXM(@RequestParam String name,@RequestParam String content){
        return name + "说：" + content;
    }

    @RequestMapping(value = "/user",method = RequestMethod.GET)
    public String hello(@RequestBody User user){
        return user.getName() + "今年：" + user.getAge()+"岁";
    }

    @RequestMapping(value = "/getUser/{id}",method = RequestMethod.GET)
    public User baseInfo(@PathVariable("id") Integer id){
        logger.info("start trace========");
        User user = new User();
        if(id == 1){
           user.setName("王晓丽");
           user.setAge(19);
        }

        return user;
    }
}
